package com.nextbus.util;
import java.io.IOException;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

/**
 * 
 * @author 
 *
 */

public class HttpDownXMl {
	@SuppressWarnings("finally")
	public static String httpDownXml(String httpUrl) throws Exception{
		String strResult=null;
		System.out.println(httpUrl);
		HttpGet httpRequest = new HttpGet(httpUrl);
		HttpClient httpclient = new DefaultHttpClient();	
		HttpResponse httpResponse = httpclient.execute(httpRequest);
		//下载成功
		if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
		{
			strResult = EntityUtils.toString(httpResponse.getEntity());
        }
		else{	
			strResult=null;
		}
		return strResult;
	}
}
